package com.shihb.esjddemo.controller;

import com.shihb.esjddemo.service.JdGoodsService;
import java.io.IOException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: Version:1.0.0
 *
 * @author shihb
 * @date 2020/4/17 23:10
 */
@RestController
@RequestMapping(value = "/jd")
public class JdGoodsController {

  @Autowired
  private JdGoodsService service;

  @GetMapping("/parse/{keyWord}")
  public Boolean parserContent(@PathVariable("keyWord") String keyWord) {

    try {
      return service.parserContent(keyWord);
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }

  @GetMapping("/search/{keyWord}/{pageNum}/{pageSize}")
  public List<Object> searchContent(
      @PathVariable("keyWord") String keyWord,
      @PathVariable("pageNum") int pageNum,
      @PathVariable("pageSize") int pageSize
  ) throws IOException {
    return service.searchContent(keyWord, pageNum, pageSize);

  }

}
